var util_swiper = function(options){
      var that = this;
      that.$items = $(options.items);
      that.$prev = options.prev ? $(options.prev) : null;
      that.$next = options.next ? $(options.next) : null;
      that.$container = that.$items.parent();
      that._show = +options.show ? +options.show : 1;
      that._page_size = +options.page_size ? +options.page_size : 1;
      that._len = that.$items.length;
      that._size = options.size ? options.size : null;
      that._direction = options.direction ? options.direction : 'top';
      that._auto = typeof options.auto != 'undefined' ? options.auto : true;
      that._i = 0;
      that._s = [];
      that._u = options.size ? options.size.split( parseInt(options.size) )[1] : 'px';
      that._timers = 0;
      that._flag = 0;
      that.doFun = function(operation){
          var _d = 0;
          operation = operation ? operation : '+';
          if (that._i == that._len && operation == '+' ){
              that._i = that._page_size;
              switch( that._direction ){
                  case 'top':
                  case 'bottom':
                      that.$container.css({ top: 0 });
                      break;
                  case 'left':
                  case 'right':
                      that.$container.css({ left: 0 });
                      break;
              }
          } else {
              switch(operation){
                  case '+':
                      that._i += that._page_size;
                  break;
                  case '-':
                      that._i -= that._page_size;
                  if( that._i < 0 ){
                      that._i = that._len;
                      var _w = 0;
                      for(var i = 0; i < that._len; i++ ){
                          _w += that._s[i];
                      }
                      switch( that._direction ){
                          case 'top':
                          case 'bottom':
                              that.$container.css({ top: -_w + that._u });
                              break;
                          case 'left':
                          case 'right':
                              that.$container.css({ left: -_w + that._u});
                              break;
                      }
                      that._i -= that._page_size;
                  }
                  break;
              }
          }
          if( that._size ){
              switch( that._direction ){
                  case 'top':
                  case 'left':
                      _d = - that._i * parseInt( that._size ) + that._u;
                      break;
                  case 'bottom':
                  case 'right':
                      _d = that._i * parseInt( that._size ) + that._u;
                      break;
              }
          }else{
              for(var i = 0; i < that._i; i++ ){
                  switch( that._direction ){
                      case 'top':
                      case 'left':
                          _d -= that._s[i];
                          break;
                      case 'bottom':
                      case 'right':
                          _d += that._s[i];
                          break;
                  }    
              }
          }
          switch( that._direction ){
              case 'top':
              case 'bottom':
                  that.$container.animate({top: _d}, 1000);
                  break;
              case 'left':
              case 'right':
                  that.$container.animate({left: _d}, 1000);
                  break;
          }
          _d = 0;
          setTimeout(function(){
              that._flag = 0;
          },1000)
      };
      if( that._len > 1 ){
          that.$items.each(function(index){
              switch( that._direction ){
                  case 'top':
                  case 'bottom':
                      that._s[index] = $(this).outerHeight();
                      break;
                  case 'left':
                  case 'right':
                      that._s[index] = $(this).outerWidth();
                      break;
              }
          });
          for(var i = 0; i < that._show; i++ ){
              switch( that._direction ){
                  case 'top':
                  case 'bottom':
                      that._s.push(that.$items.eq(i).outerHeight());
                      break;
                  case 'left':
                  case 'right':
                      that._s.push(that.$items.eq(i).outerWidth());
                      break;
              }
              that.$container.append(that.$items.eq(i).clone());
          }
          switch( that._direction ){
              case 'left':
              case 'right':
                  var _w = 0;
                  for(var i = 0; i < that._s.length; i++ ){
                      _w += that._s[i];
                  }
                  that.$container.css('width',_w + that._u);
                  break;
          }
          if( that._auto ){
              that._timers = setInterval(function(){
                  that.doFun();
              },2000);
              that.$container.hover(
                  function(){
                      clearInterval(that._timers);
                      that._timers = 0;
                  },
                  function(){
                      if( that._timers == 0 ){
                          that._timers = setInterval(function(){
                              that.doFun();
                          },2000);
                      }
                  }
              );
          } 
          if( that.$prev && that.$prev.length ){
              that.$prev.on('click',function(){
                  if( that._flag == 0 ){
                      that._flag = 1;
                      clearInterval(that._timers);
                      that._timers = 0;
                      that.doFun('-');
                      if( that._auto ){
                          that._timers = setInterval(function(){
                              that.doFun();
                          },3000);
                      }
                  }
              });
          }
          if( that.$next && that.$next.length ){
              that.$next.on('click',function(){
                  if( that._flag == 0 ){
                      that._flag = 1;
                      clearInterval(that._timers);
                      that._timers = 0;
                      that.doFun('+');
                      if( that._auto ){
                          that._timers = setInterval(function(){
                              that.doFun();
                          },3000);
                      }
                  }
              });
          }
      }
  }